").join(">").split('"').join(""").split("'").join("'")}});a.extend(a.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){__=__.concat($item.nest($1,$2));}"},wrap:{_default:{$2:"null"},open:"$item.calls(__,$1,$2);__=[];",close:"call=$item.calls();__=call._.concat($item.wrap(call,__));"},each:{_default:{$2:"$index, $value"},open:"if($notnull_1){$.each($1a,function($2){with(this){",close:"}});}"},"if":{open:"if(($notnull_1)&&$1a){",close:"}"},"else":{_default:{$1:"true"},open:"}else if(($notnull_1)&&$1a){"},html:{open:"if($notnull_1){__.push($1a);}"},"=":{_default:{$1:"$data"},open:"if($notnull_1){__.push($.encode($1a));}"},"!":{open:""}},complete:function(){b={}},afterManip:function(f,b,d){var e=b.nodeType===11?a.makeArray(b.childNodes):b.nodeType===1?[b]:[];d.call(f,b);m(e);c++}});function j(e,g,f){var b,c=f?a.map(f,function(a){return typeof a==="string"?e.key?a.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+d+'="'+e.key+'" $2'):a:j(a,e,a._ctnt)}):e;if(g)return c;c=c.join("");c.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,function(f,c,e,d){b=a(e).get();m(b);if(c)b=k(c).concat(b);if(d)b=b.concat(k(d))});return b?b:k(c)}function k(c){var b=document.createElement("div");b.innerHTML=c;return a.makeArray(b.childNodes)}function o(b){return new Function("jQuery","$item","var $=jQuery,call,__=[],$data=$item.data;with($data){__.push('"+a.trim(b).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{=$1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,function(m,l,k,g,b,c,d){var j=a.tmpl.tag[k],i,e,f;if(!j)throw"Unknown template tag: "+k;i=j._default||[];if(c&&!/\w$/.test(b)){b+=c;c=""}if(b){b=h(b);d=d?","+h(d)+")":c?")":"";e=c?b.indexOf(".")>-1?b+h(c):"("+b+").call($item"+d:b;f=c?e:"(typeof("+b+")==='function'?("+b+").call($item):("+b+"))"}else f=e=i.$1||"null";g=h(g);return"');"+j[l?"close":"open"].split("$notnull_1").join(b?"typeof("+b+")!=='undefined'&&("+b+")!=null":"true").split("$1a").join(f).split("$1").join(e).split("$2").join(g||i.$2||"")+"__.push('"})+"');}return __;")}function n(c,b){c._wrap=j(c,true,a.isArray(b)?b:[q.test(b)?b:a(b).html()]).join("")}function h(a){return a?a.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null}function s(b){var a=document.createElement("div");a.appendChild(b.cloneNode(true));return a.innerHTML}function m(o){var n="_"+c,k,j,l={},e,p,h;for(e=0,p=o.length;e=0;h--)m(j[h]);m(k)}function m(j){var p,h=j,k,e,m;if(m=j.getAttribute(d)){while(h.parentNode&&(h=h.parentNode).nodeType===1&&!(p=h.getAttribute(d)));if(p!==m){h=h.parentNode?h.nodeType===11?0:h.getAttribute(d)||0:0;if(!(e=b[m])){e=f[m];e=g(e,b[h]||f[h]);e.key=++i;b[i]=e}c&&o(m)}j.removeAttribute(d)}else if(c&&(e=a.data(j,"tmplItem"))){o(e.key);b[e.key]=e;h=a.data(j.parentNode,"tmplItem");h=h?h.key:0}if(e){k=e;while(k&&k.key!=h){k.nodes.push(j);k=k.parent}delete e._ctnt;delete e._wrap;a.data(j,"tmplItem",e)}function o(a){a=a+n;e=l[a]=l[a]||g(e,b[e.parent.key+n]||e.parent)}}}function u(a,d,c,b){if(!a)return l.pop();l.push({_:a,tmpl:d,item:this,data:c,options:b})}function w(d,c,b){return a.tmpl(a.template(d),c,b,this)}function x(b,d){var c=b.options||{};c.wrapped=d;return a.tmpl(a.template(b.tmpl),b.data,c,b.item)}function v(d,c){var b=this._wrap;return a.map(a(a.isArray(b)?b.join(""):b).filter(d||"*"),function(a){return c?a.innerText||a.textContent:a.outerHTML||s(a)})}function t(){var b=this.nodes;a.tmpl(null,null,null,this).insertBefore(b[0]);a(b).remove()}})(jQuery);
(function ($){
if(!$) return;
var ua=navigator.userAgent,
isIE=ua.match(/msie/i),
isIE6=isIE&&ua.match(/msie 6\./i),
location=window.location,
isHttpsScheme=location&&location.protocol&&location.protocol=='https:';
$.extend({
amazonjs:{
imageAttributes: ['SmallImage', 'MediumImage', 'LargeImage'],
isCustomerReviewEnabled: false,
isTrackEventEnabled: false,
resource: {},
initTemplate:function (){
var r=this.resource;
var linkOpenTag='';
var smallImageTemplate =
[
'{{if SmallImage}}',
'{{if $item.setInfoMargin(SmallImage.width+10)}}{{/if}}',
'',
linkOpenTag,
'
',
'',
'
',
'{{/if}}'
].join('');
var mediumImageTemplate =
[
'{{if MediumImage}}',
'{{if $item.setInfoMargin(MediumImage.width+10)}}{{/if}}',
'',
linkOpenTag,
'
',
'',
'
',
'{{/if}}'
].join('');
var largeImageTemplate =
[
'{{if LargeImage}}',
'{{if $item.setInfoMargin(LargeImage.width+10)}}{{/if}}',
'',
linkOpenTag,
'
',
'',
'
',
'{{/if}}'
].join('');
var imageTemplate =
[
'{{if _ShowSmallImage}}',smallImageTemplate,'{{/if}}',
'{{if _ShowMediumImage}}',mediumImageTemplate,'{{/if}}',
'{{if _ShowLargeImage}}',largeImageTemplate,'{{/if}}'
].join('');
var linkTemplate=linkOpenTag + '${Title}';
var priceContentTemplate =
[
'{{if $item.isSale()}}',
'' + r.ListPrice + '${ListPrice.FormattedPrice}
',
'{{if OfferSummary.LowestNewPrice}}' + r.Price + '${OfferSummary.LowestNewPrice.FormattedPrice}{{/if}}',
'' + r.PriceUpdatedat + '',
'{{else}}',
'' + r.Price + '${ListPrice.FormattedPrice}',
'' + r.PriceUpdatedat + '',
'{{/if}}'
].join('');
var priceTemplate='{{if ListPrice}}
' + priceContentTemplate + '
{{/if}}';
var priceLiTemplate='{{if ListPrice}}' + priceContentTemplate + '{{/if}}';
var reviewLinkTemplate='';
if(this.isCustomerReviewEnabled){
reviewLinkTemplate='' + r.SeeCustomerReviews + '';
}
this.partial={
smallImage:smallImageTemplate,
mediumImage:mediumImageTemplate,
largeImage:largeImageTemplate,
link:linkTemplate,
price:priceTemplate
};
var defaultTemplates={
Small:[
'',
imageTemplate,
'{{if _ShowDefaultImage}}',smallImageTemplate,'{{/if}}',
'
',
'
',linkTemplate,'
',
'
',
'{{if Creator}}- ${Creator}
{{/if}}',
'{{if Manufacturer}}- ${Manufacturer}
{{/if}}',
priceLiTemplate,
'{{if PublicationDate}}- ' + r.PublicationDate + '${PublicationDate}
{{/if}}',
'{{if SalesRank}}- ' + r.SalesRank + '' + r.SalesRankValue + '
{{/if}}',
'
',
'
',
reviewLinkTemplate,
'',
'
'
],
Music:[
'',
imageTemplate,
'{{if _ShowDefaultImage}}',mediumImageTemplate,'{{/if}}',
'
',
'
',linkTemplate,'
',
'
',
'{{if Artist}}- ${Artist}
{{/if}}',
'{{if Creator}}- ${Creator}
{{/if}}',
'{{if Label}}- ${Label}
{{/if}}',
priceLiTemplate,
'{{if ReleaseDate}}- ' + r.ReleaseDate + '${ReleaseDate}
{{/if}}',
'{{if SalesRank}}- ' + r.SalesRank + '' + r.SalesRankValue + '
{{/if}}',
'{{if RunningTime}}- ' + r.RunningTime + '' + r.RunningTimeValue + '
{{/if}}',
'
',
'
',
reviewLinkTemplate,
'',
'
'
],
DVD:[
'',
imageTemplate,
'{{if _ShowDefaultImage}}',mediumImageTemplate,'{{/if}}',
'
',
'
',linkTemplate,'
',
'
',
'{{if Director}}- ${Director}
{{/if}}',
'{{if Actor}}- ${Actor}
{{/if}}',
'{{if Label}}- ${Label}
{{/if}}',
priceLiTemplate,
'{{if ReleaseDate}}- ' + r.ReleaseDate + '${ReleaseDate}
{{/if}}',
'{{if SalesRank}}- ' + r.SalesRank + '' + r.SalesRankValue + '
{{/if}}',
'{{if RunningTime}}- ' + r.RunningTime + '' + r.RunningTimeValue + '
{{/if}}',
'
',
'
',
reviewLinkTemplate,
'',
'
'
],
Book:[
'',
imageTemplate,
'{{if _ShowDefaultImage}}',mediumImageTemplate,'{{/if}}',
'
',
'
',linkTemplate,'
',
'
',
'{{if Author}}- ' + r.BookAuthor + '${Author}
{{/if}}',
priceLiTemplate,
'- ' + r.BookPublicationDate + '${PublicationDate}
',
'{{if SalesRank}}- ' + r.SalesRank + '' + r.SalesRankValue + '
{{/if}}',
'- ${Binding}' + r.NumberOfPagesValue + '
',
'- ISBN-10${ISBN}
',
'- ISBN-13${EAN}
',
'- ' + r.BookPublisher + '${Publisher}
',
'
',
'
',
reviewLinkTemplate,
'',
'
'
],
eBooks:[
'',
imageTemplate,
'{{if _ShowDefaultImage}}',mediumImageTemplate,'{{/if}}',
'
',
'
',linkTemplate,'
',
'
',
'{{if Author}}- ' + r.BookAuthor + '${Author}
{{/if}}',
priceLiTemplate,
'- ' + r.BookPublicationDate + '${PublicationDate}
',
'{{if SalesRank}}- ' + r.SalesRank + '' + r.SalesRankValue + '
{{/if}}',
'- ${Binding}' + r.NumberOfPagesValue + '
',
'- ' + r.BookPublisher + '${Publisher}
',
'
',
'
',
reviewLinkTemplate,
'',
'
'
]
};
this.template(defaultTemplates);
var me=this;
$.each(this.addTemplateCallbacks, function (i, callback){
var t=callback.call(me, me.partial);
if(t) me.template(t);
});
},
addTemplateCallbacks:[],
addTemplate:function (fn){
if(typeof(fn)=='function'){
this.addTemplateCallbacks.push(fn);
}},
template:function (templates){
$.each(templates, function (name, tmpl){
if(tmpl){
$.template('amazonjs' + name + 'Tpl', (typeof tmpl==='string') ? tmpl:tmpl.join(''));
}});
},
render:function (items){
var $items=[];
this.initTemplate();
$(".amazonjs_item").each(function (){
var classNames=$(this).attr('class').split(' '),
c=classNames[0].split('_'),
asin=c[1],
countryCode=c[2],
tmpl=(c.length > 3) ? c[3]:null,
item=find(asin, countryCode),
imgSize=$(this).attr('data-img-size')
;
if(item){
item._ImageSize=imgSize||'';
var $item=$.amazonjs.tmpl(item, $.amazonjs.formatTmplName(tmpl));
$(this).replaceWith($item.hide());
var $review=$item.find('.amazonjs_review');
if(isIE6){
$item.css('position', 'static');
$review.css({
'float':'right',
'position':'static',
'marginRight':'32px'
});
}
$review.click(function (){
tb_show(this.title, this.href);
this.blur();
return false;
});
if($.amazonjs.isTrackEventEnabled){
$item.find('.amazonjs_link').click(function(){
try {
var data=$(this).data();
var title=$(this).attr('title');
if(data.role=='amazonjs_product'){
if($.isFunction(ga)){
ga('send', 'event', 'AmazonJS', 'Click', data.asin + ' ' + title);
}else if(_gaq){
_gaq.push(['_trackEvent', 'AmazonJS', 'Click', data.asin + ' ' + title]);
}}
} catch (e){
}});
}
$items.push($item);
}else{
tmpl='Link' + countryCode.toUpperCase();
item={
asins:asin,
fc1:'000000',
lc1:'0000FF',
bc1:'000000',
bg1:'FFFFFF',
IS2:1,
lt1:'_blank',
f:'ifr',
m:'amazon'
};
var $item=$.amazonjs.tmpl(item, $.amazonjs.formatTmplName(tmpl));
$(this).replaceWith($item);
}});
function find(asin, countryCode){
for (var i=0, length=items.length; i < length; i++){
if(items[i].ASIN==asin&&items[i].CountryCode==countryCode){
return items[i];
}}
}
if($.amazonjs.isFadeInEnabled){
function fadeIn(){
if($items.length > 0){
var $item=$items.shift();
$item.fadeIn();
setTimeout(fadeIn, 100);
}}
fadeIn();
}else{
$.each($items, function(){
this.show();
});
}},
formatTmplName:function (key){
return (key) ? 'amazonjs' + key + 'Tpl':null;
},
formatNumber:function (val){
val +='';
var x=val.split('.'),
x1=x[0],
x2=x.length > 1 ? '.' + x[1]:'',
rgx=/(\d+)(\d{3})/;
while (rgx.test(x1)){
x1=x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
},
formatDateTime:function (timestamp){
var dt=new Date(timestamp * 1000);
var Y=dt.getFullYear(),
m=dt.getMonth() + 1,
d=dt.getDate(),
H=dt.getHours(),
i=dt.getMinutes();
if(m < 10) m='0' + m;
if(d < 10) d='0' + d;
if(H < 10) H='0' + H;
if(i < 10) i='0' + i;
return Y + '/' + m + '/' + d + ' ' + H + ':' + i;
},
getTemplate:function (item){
var defaultTmpl=this.formatTmplName('Small');
if(item&&item.ProductGroup){
var tmpl=this.formatTmplName(item.ProductGroup);
return $.template[tmpl]||defaultTmpl;
}
return defaultTmpl;
},
prepareData:function (item){
if(isHttpsScheme){
$.each(this.imageAttributes, function(i, v){
var image=item[v];
if(image&&image.src){
image.src=image.src.replace('http://ecx.images-amazon.com', 'https://images-eu.ssl-images-amazon.com');
}});
}
item._ShowDefaultImage=_ShowSmallImage=item._ShowMediumImage=item._ShowLargeImage=false;
if(item._ImageSize=='small') item._ShowSmallImage=true;
else if(item._ImageSize=='medium') item._ShowMediumImage=true;
else if(item._ImageSize=='large') item._ShowLargeImage=true;
else item._ShowDefaultImage=true;
item.PublicationDate=item.PublicationDate||item.ReleaseDate;
item.Manufacturer=item.Manufacturer||item.Label;
if(item.SalesRank) item.SalesRank=this.formatNumber(item.SalesRank);
if(item.PublicationDate) item.PublicationDate=item.PublicationDate.replace(/-/g, '/');
if(item.ReleaseDate) item.ReleaseDate=item.ReleaseDate.replace(/-/g, '/');
if(item.Artist&&item.Creator){
var Creator=[];
var a=$.isArray(item.Artist) ? item.Artist:[item.Artist];
var c=$.isArray(item.Creator) ? item.Creator:[item.Creator];
$.each(c, function (i, value){
if($.inArray(value, a)==-1) Creator.push(value);
});
item.Creator=(Creator.length) ? Creator:null;
}
item.UpdatedDate=this.formatDateTime(item.UpdatedAt);
return item;
},
tmpl:function (item, tmpl){
item=this.prepareData(item);
if(!item.ListPrice&&item.OfferSummary){
item.ListPrice=item.OfferSummary.LowestNewPrice;
}
return $.tmpl($.template[tmpl]||this.getTemplate(item), item, {
isSale:function (){
if(this.data){
var lp=this.data.ListPrice, la=Number(lp.Amount),
os=this.data.OfferSummary||{}, sp=os.LowestNewPrice||{}, sa=Number(sp.Amount);
return (!isNaN(sa)&&sa < la);
}
return false;
},
setInfoMargin: function(margin){
return this.data._InfoMarginLeft=margin;
}});
},
execute: function(){
var amazonjsVars=window.amazonjsVars;
if(amazonjsVars){
function render(){
if(!amazonjsVars.items){
return;
}
if($.amazonjs.isExecuted){
return;
}
if(amazonjsVars.isCustomerReviewEnabled){
if(typeof tb_pathToImage==='undefined'){
tb_pathToImage=amazonjsVars.thickboxUrl + '/loadingAnimation.gif';
}
if(typeof tb_closeImage==='undefined'){
tb_closeImage=amazonjsVars.thickboxUrl + '/tb-close.png';
}}
$.amazonjs.isFadeInEnabled=amazonjsVars.isFadeInEnabled;
$.amazonjs.isCustomerReviewEnabled=amazonjsVars.isCustomerReviewEnabled;
$.amazonjs.isTrackEventEnabled=amazonjsVars.isTrackEventEnabled;
$.amazonjs.resource=amazonjsVars.resource;
$.amazonjs.template(amazonjsVars.regionTemplate);
$.amazonjs.render(amazonjsVars.items);
$.amazonjs.isExecuted=true;
}
if(amazonjsVars.isFadeInEnabled){
setTimeout(function (){
render();
}, 1000);
}else{
render();
}}
}}
});
$(document).ready(function(){
$.amazonjs.execute();
});
$(window).load(function(){
$.amazonjs.execute();
});
if(document.addEventListener){
document.addEventListener('DOMContentLoaded', function (){
$.amazonjs.execute();
});
}})(jQuery);